package com.springcloud.system.user.controller;


import com.springcloud.common.core.entity.R;
import com.springcloud.common.entity.Resource;
import com.springcloud.system.user.service.ResourceService;
import org.springframework.web.bind.annotation.*;

import java.util.Set;

/**
 * <p>
 * </p>
 *
 * @author mori
 * @since 2019-11-04
 */
@RestController
@RequestMapping("/resource")
public class ResourceController {

    private ResourceService resourceService;

    public ResourceController(ResourceService resourceService) {
        this.resourceService = resourceService;
    }

    /**
     * 加载所有资源
     *
     * @return
     */
    @GetMapping(value = "/all")
    public R<Set<Resource>> resources() {
        return R.ok(resourceService.resources());
    }

    /**
     * 根据username加载对应的资源
     *
     * @param username
     * @return
     */
    @GetMapping(value = "/user")
   public R<Set<Resource>> resources(@RequestParam("username") String username) {
        return R.ok(resourceService.resources(username));
    }
}

